using System;
using BitMango;
using BitMango.Diagnostics;
using Data;
using TMPro;
using UnityEngine;

public class LevelWidgetHandler : MonoBehaviour, IWidget, IHandlerBase
{
	public void SetData(Level _data)
	{
		Debugger.Assert(_data != null, "LevelWidgetHandler _data != null");
		this.data = _data;
		this.DoDataExchange();
	}

	public void DoDataExchange()
	{
		if (this.data.record.locked)
		{
			this.tweenItem.enabled = false;
			this.text.gameObject.SetActive(false);
			this.sprite.SetSprite("btn_level_locked");
		}
		else
		{
			this.tweenItem.enabled = true;
			this.text.gameObject.SetActive(true);
			this.text.text = string.Format("{0}", this.data.num + 1);
			if (this.data.record.isClear)
			{
				this.sprite.SetSprite("btn_level_play");
			}
			else
			{
				this.sprite.SetSprite("btn_level_now");
			}
		}
		if (!string.IsNullOrEmpty(this.data.pictureTheme))
		{
			this.collection.SetActive(true);
		}
		else
		{
			this.collection.SetActive(false);
		}
	}

	private void OnClick_Self()
	{
		if (!Profile.IsEnableCheat)
		{
			if (this.data.record.locked)
			{
				return;
			}
		}
		BMSoundHelper.Play("se_btnclick", false, 1f);
		LevelSceneHandler component = Scene.FindSceneRoot(base.transform.parent.gameObject).GetComponent<LevelSceneHandler>();
		component.OnClick_stage(this);
	}

	public Level data;

	public TextMeshPro text;

	public tk2dSprite sprite;

	public tk2dUITweenItem tweenItem;

	public GameObject collection;
}
